﻿#include <iostream>
#include <fstream>
#include <ctime>

using namespace std;

int numbers[5000];

void bubbleSort(int cat[])
{
	for (size_t i = 0; i < 4999; i++)
	{

		for (size_t j = 0; j < 4999 - i; j++)
		{
			if (cat[j] > cat[j + 1])
			{
				int a = cat[j];
				cat[j] = cat[j + 1];
				cat[j + 1] = a;
			}
		}
	}
}

void readFile(string fileName)
{
	fstream file(fileName);
	if (file.is_open())
	{
		for (size_t i = 0; i < 5000; i++)
		{
			file >> numbers[i];
		}
		clock_t start = clock();
		bubbleSort(numbers);
		clock_t end = clock();
		cout << fileName << " " << end - start << " " << "milliseconds " << endl;
	}
	else cout << "Fail open: " << fileName << endl;
	file.close();
}

int main()
{
	readFile("m1_sorted.txt");
	readFile("m2_reverse.txt");
	readFile("m3_shuffle.txt");
}